package com.fubowen.reader.db.bean

import android.view.View
import android.widget.TextView
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Fts4
import androidx.room.FtsOptions
import androidx.room.PrimaryKey
import com.fubowen.reader.R
import com.fubowen.reader.adapter.ISimple

@Fts4(
    tokenizer = FtsOptions.TOKENIZER_ICU,
    notIndexed = ["description", "parentId", "url", "keywords"]
)
@Entity
class Document @JvmOverloads constructor(
    var name: String = "",
    var description: String = "",
    var parentId: Int = 0,
    var url: String = "",
    var keywords: Int = 0,
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "rowid") var
    id: Int = 0
) : ISimple<Document> {

    override fun isSame(new: Document) = name == new.name

    override fun isSameOfContent(new: Document) = name == new.name

    override fun onBind(view: View, id: Int) {
        view.findViewById<TextView>(R.id.name).text = url
    }
}